package br.com.iplant.mb;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import br.com.iplant.dao.DoencaDAO;
import br.com.iplant.vo.Doenca;
import javax.swing.JCheckBox;


public class CadastroDoenca extends JPanel {
	private JTextField tfDescricao;
	private JTextField tfSintomas;
	Doenca doenca = new Doenca();
	DoencaDAO doencaDAO = new DoencaDAO();
	private JTextField tfNomeCientifico;
	private JTextField tfControles;
	JCheckBox ckFungos;
	JCheckBox ckBacterias;
	JCheckBox ckVirus;
	JCheckBox ckNematoides;

	/**
	 * Create the panel.
	 */
	public CadastroDoenca() {
		setLayout(null);
		
		JLabel lblDescricao = new JLabel("Descri\u00E7\u00E3o:");
		lblDescricao.setBounds(10, 11, 66, 14);
		add(lblDescricao);
		
		tfDescricao = new JTextField();
		tfDescricao.setBounds(10, 26, 162, 20);
		add(tfDescricao);
		tfDescricao.setColumns(10);
		
		JLabel lblSintomas = new JLabel("Sintomas:");
		lblSintomas.setBounds(10, 56, 55, 14);
		add(lblSintomas);
		
		tfSintomas = new JTextField();
		tfSintomas.setBounds(10, 71, 409, 20);
		add(tfSintomas);
		tfSintomas.setColumns(10);
		
		JButton btnSalvar = new JButton("Salvar");
		btnSalvar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			}
		});
		btnSalvar.setBounds(26, 181, 89, 23);
		add(btnSalvar);
		
		JButton btnFechar = new JButton("Fechar");
		btnFechar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		btnFechar.setBounds(184, 181, 89, 23);
		add(btnFechar);
		
		JLabel lblNomeCientfico = new JLabel("Nome Cient\u00EDfico:");
		lblNomeCientfico.setBounds(183, 11, 90, 14);
		add(lblNomeCientfico);
		
		tfNomeCientifico = new JTextField();
		tfNomeCientifico.setBounds(182, 26, 237, 20);
		add(tfNomeCientifico);
		tfNomeCientifico.setColumns(10);
		
		JLabel lblControles = new JLabel("Controles:");
		lblControles.setBounds(10, 100, 66, 14);
		add(lblControles);
		
		tfControles = new JTextField();
		tfControles.setBounds(10, 114, 409, 20);
		add(tfControles);
		tfControles.setColumns(10);
		
		ckFungos = new JCheckBox("Fungos");
		ckFungos.setBounds(10, 141, 97, 23);
		add(ckFungos);
		
		ckBacterias = new JCheckBox("Bacterias");
		ckBacterias.setBounds(112, 141, 97, 23);
		add(ckBacterias);
		
		ckVirus = new JCheckBox("Virus");
		ckVirus.setBounds(211, 141, 97, 23);
		add(ckVirus);
		
		ckNematoides = new JCheckBox("Nematoides");
		ckNematoides.setBounds(310, 141, 97, 23);
		add(ckNematoides);
	
	}
	public void salvar(){
		doenca.setDescricao(tfDescricao.getText());
		doenca.setSintomas(tfSintomas.getText());
		doenca.setControle(tfControles.getText());
		doenca.setNomeCientifico(tfNomeCientifico.getText());
		
		doencaDAO.salvar(doenca);
	}
}
